home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / NGMan.lha / NGMan next >
Text File  |  1995-06-16  |  21KB  |  674 lines

  1.              /*************************************************/
  2.              /*   NGMan Version 1.3 by Steve Collins          */
  3.              /*       email steve@stuffs.demon.co.uk          */
  4.              /* http://metro.turnpike.net/C/cheeky/INDEX.HTML */
  5.              /*************************************************/
  6.  
  7.  
  8.           /*******************************************************/
  9.          /*  Make sure the following five entries suit your setup */
  10.           /*******************************************************/
  11.  
  12. NEWS_DIR = "UUlib:"        /* Directory that contains your Newsgroups file */
  13. NEWS_NAME = "Newsgroups"   /* Name of your Newsgroups file                 */
  14.  
  15. NEW_DIR = "UUspool:"       /* Directory that contains your new groups file */
  16.                            /*                              ---             */
  17. NEW_NAME = "Newgroups"     /* Name of your new groups file                 */
  18.                            /*              ---                             */
  19.                            /* If you don't have a new groups file you will */
  20.                            /* still be able to use NGMan but all options   */
  21.                            /* relating to it will be unavailable.          */
  22.  
  23. ACTIVE_LIST = "UUlib:active.newsgroups"  /* Path to your active newsgroup list */
  24.  
  25.              /*************************************************/
  26.              /* The following can also be changed if you want */
  27.              /*************************************************/
  28.  
  29. IGNORE = ""         /* Default ignore pattern, see docs for more info */
  30.  
  31. DEF_MAX = 10        /* Max entries to be shown per page.           */
  32.                     /* 13 max suggested for non interlace screens  */
  33.                     /* 30 max for interlace/DBLPAL screens         */
  34.  
  35. DEF_DAYS = 2        /* Default days to keep messages                 */
  36.  
  37. CONFIRM = 1         /* 1 = Confirm deletion, 0 = Don't confirm       */
  38.  
  39. SORT_NEW = 1        /* 1 = Display new groups sorted alphabetically  */
  40.                     /* 0 = Display unsorted                          */
  41.  
  42. SCREEN = ""         /* Public screen you want the requesters to appear on. */
  43.                     /* Rexxreqtools will try to open it's requesters on    */
  44.                     /* whatever screen it was called from, but sometimes   */
  45.                     /* it seems to need a little persuasion ;)             */
  46.  
  47. REQWIDTH = 60       /* Prevents looong entries from running off the edge of   */
  48.                     /* the requester. '60' is a good general setting but you  */
  49.                     /* can alter it if you want.                              */
  50.  
  51. PROGTXT = 1         /* 1 = Show info about current search & ignore pattern in */
  52.                     /* search progress window,                                */
  53.                     /* 0 = Don't show info                                    */
  54.  
  55.  
  56.                   /*******************************/
  57.                   /* Alter the rest at your peril*/
  58.                   /*******************************/
  59.  
  60. OPTIONS RESULTS
  61. SIGNAL on BREAK_C     
  62.  
  63. NL = '0a'x
  64. CSI = '9b'x
  65. ESC = '1b'x
  66. PLAIN_TXT = CSI||'30'x||'6d'x
  67. BOLD_TXT = CSI||'31'x||'6d'x
  68. BEEP = '07'x
  69. TITLE = "NGMan 1.3"
  70. DATE = "14/6/95"
  71. CHANGES = 0
  72.  
  73. CTAG = "rtez_flags=ezreqf_centertext"
  74. if SCREEN ~= "" then STAG = "rt_pubscrname = " || SCREEN
  75. else STAG = ""
  76.  
  77. KEYWORD = ""   
  78. MAIN_FILE = NEWS_DIR || NEWS_NAME
  79. TEMP_FILE = "T:" || NEWS_NAME
  80. NEW_LIST = NEW_DIR || NEW_NAME
  81. NEW_TEMP = "T:" || NEW_NAME
  82. HITLIST = "T:hitlist.tmp"
  83.  
  84. if ~ exists(NEWS_DIR || NEWS_NAME) then do
  85. say "Can't find" NEWS_DIR || NEWS_NAME NL "..check configuration"
  86. exit
  87. end
  88.  
  89. if ~ exists("libs:rexxreqtools.library") then do
  90. say "Can't find rexxreqtools.library, aborting.."
  91. exit
  92. end
  93.  
  94. if ~ show('L',"rexxreqtools.library") then do
  95. addlib('rexxreqtools.library',0,-30,0)
  96. end
  97.  
  98. address command
  99. 'copy' MAIN_FILE 'to T: NOREQ QUIET'
  100. call CREATE_NEWTMP
  101. call UPDATE_VARS  
  102.  
  103. /********** The Initial requester **********/
  104.  
  105. MAIN:
  106. SHOWN = 1
  107.  
  108. call rtezrequest("-" TOTAL "Newsgroups found in" NEWS_DIR || NEWS_NAME"-" NL,
  109.                  CHANGES "changes made","View|Add|Browse|Search|About|Save & Exit|Abort",TITLE,STAG CTAG,)
  110.  
  111. if rtresult = 0 then do
  112. call DELFILE(TEMP_FILE)
  113. call DELFILE(HITLIST)
  114. call DELFILE(HITLIST".old")
  115. call DELFILE(NEW_TEMP)
  116. exit
  117. end
  118.  
  119. if rtresult = 1 & TOTAL >= 1 then signal VIEW /* Go to VIEW and possibly on to EDIT/DELETE */
  120. if rtresult = 1 & TOTAL = 0 then signal MAIN  /* No Newsgroups so nothing to view          */
  121.  
  122. if rtresult = 2 then do                       /* ADD selected                              */
  123.  SOURCE = "MAIN"
  124.  call ADD
  125.  signal MAIN
  126.  end
  127.  
  128. if rtresult = 3 then do
  129.    call rtezrequest("Browse which file..","Active|Hitlist|New",TITLE,STAG,)
  130.    if rtresult = 0 then do; BROWSE_LIST = NEW_TEMP; BROWSETXT = "newgroups"; end
  131.    if rtresult = 2 then do; BROWSE_LIST = HITLIST".old"; BROWSETXT = HITS "matches on '"KEYWORD"'"; end
  132.    if rtresult = 1 then do; BROWSE_LIST = ACTIVE_LIST; BROWSETXT = "active newsgroups"; end
  133. call BROWSE
  134. signal MAIN
  135. end
  136.  
  137. if rtresult = 4 then do
  138.    call rtezrequest("Search which file..","Active|Hitlist|New",TITLE,STAG,)
  139.    if rtresult = 0 then SEARCH_LIST = NEW_TEMP
  140.    if rtresult = 2 then SEARCH_LIST = HITLIST".old"
  141.    if rtresult = 1 then SEARCH_LIST = ACTIVE_LIST
  142.    call SEARCH
  143.    signal MAIN
  144.    end
  145.  
  146. if rtresult = 5 then do; call ABOUT; signal MAIN; end  /* Show the about requester */
  147.  
  148. if rtresult = 6 then do
  149. call SAVE
  150. call DELFILE(HITLIST)
  151. call DELFILE(HITLIST".old")
  152. exit
  153. end          /* Quit, saving changes */
  154.  
  155. /**************** VIEW selected *****************/
  156. /* First create the body text for the requester */
  157. /************************************************/
  158.  
  159. VIEW:
  160. CHECK = 0
  161. BODYTEXT = ""
  162. SHOWN_OLD = SHOWN
  163. CHECK_OLD = CHECK
  164.  
  165. VIEW2:
  166. do i = SHOWN to TOTAL
  167. if ENTRY.i = "" then iterate
  168.  
  169. TEXT = ENTRY.i
  170. if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
  171.  
  172. BODYTEXT = BODYTEXT "("i")" TEXT || NL
  173. SHOWN = SHOWN + 1
  174. CHECK = CHECK + 1
  175. if CHECK = DEF_MAX then leave
  176. end
  177.  
  178. select
  179.  
  180.   when TOTAL <= DEF_MAX then do
  181.   GDGTS = "-|Leave|Edit|Delete|Sort|Add|-"       /* Only one page */
  182.   RTAGS = "rtez_defaultresponse = 2"
  183.   end 
  184.  
  185.   when SHOWN = TOTAL + 1 then do
  186.   GDGTS = "-|Leave|Edit|Delete|Sort|Add|<<"         /* Last page */
  187.   RTAGS = "rtez_defaultresponse = 2"
  188.   end
  189.  
  190.   when SHOWN - CHECK = 1 then do
  191.   GDGTS = ">>|Leave|Edit|Delete|Sort|Add|-"         /* First page */
  192.   RTAGS = "rtez_defaultresponse = 1"
  193.   end
  194.  
  195.   otherwise do
  196.   GDGTS = ">>|Leave|Edit|Delete|Sort|Add|<<"           /* Intermediate pages */
  197.   RTAGS = "rtez_defaultresponse = 1"
  198.   end
  199. end
  200.  
  201. /************ Display the requester ************/
  202. /***** with options to EDIT, DELETE or ADD *****/
  203.  
  204. VIEW_REQ:
  205. if TOTAL = 0 then BODYTEXT = ""         /* No Newsgroups found */
  206. call rtezrequest(BODYTEXT NL || "   " SHOWN - 1 "shown," (TOTAL + 1) - SHOWN "remaining..",GDGTS,TITLE,RTAGS STAG,)
  207.  
  208. if rtresult = 2 then do; SHOWN = 0; signal MAIN; end              /* FINISHED */
  209. if rtresult = 1 & SHOWN = TOTAL + 1 then do; signal VIEW_REQ; end /* MORE but none left to show*/
  210. if rtresult = 1 then do; signal VIEW; end                         /* MORE */
  211. if rtresult = 0 then do                                           /* BACK */
  212.  if SHOWN - CHECK = 1 then do; SHOWN = 1; signal VIEW; end
  213.  if SHOWN > TOTAL then SHOWN = SHOWN - (CHECK + DEF_MAX)
  214.  else SHOWN = SHOWN_OLD - CHECK
  215.  signal VIEW
  216. end
  217.  
  218.  
  219. /********** ADD selected **********/
  220. if rtresult = 6 then do    
  221.  
  222. ADD:
  223. GROUP = rtgetstring(,"Enter an Newsgroup.."NL,
  224.                    "(blank to cancel)",TITLE,"OK",CTAG STAG,)
  225.  
  226. if rtresult = "" | rtresult = 0 then do
  227.  if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
  228.  else signal VIEW_REQ
  229. end
  230.  
  231. DAYS = rtgetstring(DEF_DAYS,"Enter days to keep"NL,
  232.                      "(blank to cancel)",TITLE,"OK",CTAG STAG,)
  233.  
  234. if rtresult = "" | rtresult = 0 then do
  235.  if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
  236.  else signal VIEW_REQ
  237. end
  238.  
  239.  
  240. TEXT = GROUP
  241. if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
  242. call rtezrequest("Following entry to be added to you Newsgroups file"NL,
  243.                  TEXT DAYS,"OK|Cancel",TITLE,CTAG STAG,)
  244.  
  245. if rtresult = 0 & SOURCE = "MAIN" then return
  246. if rtresult = 0 & SOURCE ~= "MAIN" then signal VIEW_REQ
  247.  
  248. NEW = TOTAL + 1
  249. ENTRY.NEW = GROUP DAYS
  250. DAYS.NEW= DAYS
  251. GROUP.NEW = GROUP
  252. TOTAL = TOTAL + 1
  253.  
  254. CHANGES = CHANGES + 1  /* Update CHANGES                */
  255. call UPDATE_TMP        /* Update T:Newsgroups..         */
  256. call UPDATE_VARS       /* Update the       variables..  */
  257. SHOWN = SHOWN_OLD      /* Restore other variables to    */
  258. CHECK = CHECK_OLD      /* original settings, to ensure  */
  259. BODYTEXT = ""          /* we return to the page that we */
  260.                        /* were called from.             */
  261.  
  262. if SOURCE = "MAIN" then do; drop SOURCE; signal MAIN; end
  263. signal VIEW2        /* Recompile text for VIEW requester */
  264.  
  265. end
  266. /*********** SORT Selected **********/
  267.  
  268. if rtresult = 5 then do
  269.  
  270. address command
  271. 'sort' TEMP_FILE TEMP_FILE
  272.  
  273. CHANGES = CHANGES + 1  /* Update CHANGES                */
  274. call UPDATE_VARS       /* Update the variables          */
  275.                        /* from the modified file in T:  */
  276.  
  277. SHOWN = SHOWN_OLD      /* Restore other variables to    */
  278. CHECK = CHECK_OLD      /* original settings, to ensure  */
  279. BODYTEXT = ""          /* we return to the page that we */
  280. signal VIEW2           /* were called from.             */
  281.  
  282. end
  283.  
  284. /*********** EDIT selected **********/
  285.  
  286. if rtresult = 3 then do
  287.  
  288. if TOTAL = 0 then signal MAIN       /* No Newsgroups so nothing to edit */
  289.  
  290. ACTION = "edit.."
  291. MINI = SHOWN - CHECK
  292. MAXI = SHOWN - 1
  293. call GETINDEX
  294. if RESULT = 0 then signal MAIN
  295.  
  296. EDIT: /* Jump back here if RE-EDIT selected */
  297. NEW_GROUP = rtgetstring(GROUP.INDEX,"Edit Newsgroup name..",TITLE,"OK",CTAG STAG,)
  298. if NEW_GROUP = "" then NEW_GROUP = GROUP.INDEX
  299.  
  300. NEW_DAYS = rtgetstring(DAYS.INDEX,"Edit days to keep..",TITLE,"OK",CTAG STAG,)
  301. if NEW_DAYS = "" then NEW_DAYS = DAYS.INDEX
  302.  
  303. /* If no alterations are made then return straight to view requester */
  304. if NEW_GROUP = GROUP.INDEX & NEW_DAYS = DAYS.INDEX then signal VIEW_REQ
  305.  
  306. TEXT = NEW_GROUP
  307. if length(TEXT) > REQWIDTH then TEXT = left(TEXT,REQWIDTH) ">>>"
  308. call rtezrequest(TEXT NEW_DAYS,"OK|Re-Edit|Abort",TITLE,CTAG STAG,)
  309.  
  310. if rtresult = 0 then signal VIEW_REQ
  311. if rtresult = 2 then signal EDIT
  312.  
  313. ENTRY.INDEX = NEW_GROUP NEW_DAYS
  314. GROUP.INDEX = NEW_GROUP
  315. DAYS.INDEX = NEW_DAYS
  316.  
  317. CHANGES = CHANGES + 1  /* Update CHANGES                */
  318. call UPDATE_TMP        /* Update T:Newsgroups           */
  319. call UPDATE_VARS       /* Update the variables..        */
  320. SHOWN = SHOWN_OLD      /* Restore other variables to    */
  321. CHECK = CHECK_OLD      /* original settings, to ensure  */
  322. BODYTEXT = ""          /* we return to the page that we */
  323. signal VIEW2           /* were called from.             */
  324. end
  325.  
  326. /*********** DELETE selected ***********/
  327.  
  328. if rtresult = 4 then do
  329.  
  330. if TOTAL = 0 then signal MAIN
  331.  
  332. ACTION = "delete.."
  333. MINI = SHOWN - CHECK
  334. MAXI = SHOWN - 1
  335. call GETINDEX
  336. if RESULT = 0 then signal MAIN
  337. if CONFIRM = 1 then do
  338. call rtezrequest("Confirm delete entry for" GROUP.INDEX"?","OK|ABORT",TITLE,CTAG STAG,)
  339. if rtresult = 0 then signal MAIN
  340. end
  341.  
  342. ENTRY.INDEX = ""
  343. CHANGES = CHANGES + 1                          /* Update CHANGES                    */
  344. call UPDATE_TMP                                /* Update T:Newsgroups               */
  345. call UPDATE_VARS                               /* Update the variables..            */
  346. if TOTAL = 0 then signal MAIN  
  347.  
  348. SHOWN = SHOWN_OLD                              /* Restore other variables to        */
  349. CHECK = CHECK_OLD                              /* original settings, to ensure      */
  350. BODYTEXT = ""                                  /* we return to the page that we     */
  351.                                                /* were called from.                 */
  352.  
  353. if SHOWN > TOTAL then SHOWN = SHOWN - DEF_MAX  /* Prevents blank view requester     */
  354.                                                /* when deleted entry was last entry */
  355.                                                /* and displayed on its own          */
  356.  
  357. signal VIEW2 
  358. end
  359.  
  360. /********** SEARCH selected from MAIN requester **********/
  361. SEARCH:
  362.  
  363. if SEARCH_LIST = HITLIST".old" & ~exists(HITLIST".old") then do
  364. call rtezrequest("You haven't searched for anything yet","OK",TITLE,STAG,)
  365. return
  366. end
  367.  
  368. call open(HLIST,HITLIST,WRITE)             
  369. if ~open(SLIST,SEARCH_LIST,READ) then do
  370. if SEARCH_LIST = NEW_TEMP then ERRORTXT = "No new groups available"
  371. else ERRORTXT =  "Can't open" SEARCH_LIST
  372. call rtezrequest(ERRORTXT,"OK",TITLE,STAG,)
  373. return
  374. end
  375.  
  376. HITS = 0
  377. IGNORED = 0
  378. SKIP = 0
  379.  
  380. GETKEY:
  381. KEYWORD = rtgetstring(KEYWORD,"Enter search string (Case insensitive)" NL "-=Blank to cancel=-",TITLE,"OK",CTAG STAG,)
  382. if KEYWORD = "" | rtresult = 0 then do
  383. call close(SLIST)
  384. call close(HLIST)
  385. call DELFILE(HITLIST)
  386. return
  387. end
  388.  
  389. if words(KEYWORD) > 1 then do
  390. call rtezrequest("-Only one keyword allowed-",OK,TITLE,STAG,)
  391. KEYWORD = compress(word(KEYWORD,1))
  392. end
  393.  
  394. SEARCH_REQ:
  395. if IGNORE = "" then IGNORETXT = "(Ignore disabled)"
  396. else IGNORETXT = "(Ignore pattern = "IGNORE")"
  397. call rtezrequest("Searching '"SEARCH_LIST"' for keyword '"KEYWORD"'"NL,
  398.                  IGNORETXT,"OK|EDIT IGNORE|EDIT KEYWORD|ABORT",TITLE,CTAG STAG,)
  399. if rtresult = 0 then do; call close(SLIST); call close(HLIST); return; end
  400. if rtresult = 2 then do
  401. IGNORE = rtgetstring(IGNORE,"Enter new pattern..",TITLE,"OK",CTAG STAG,)
  402. signal SEARCH_REQ
  403. end
  404. if rtresult = 3 then signal GETKEY
  405.  
  406. /* Open the SEARCH PROGRESS window */
  407. call open(progress_window,'RAW:100/100/400/100/'TITLE '(Control-C to abort)')
  408.  
  409. if PROGTXT = 1 then do
  410. call writech(progress_window,"Keyword >" BOLD_TXT||KEYWORD||PLAIN_TXT NL)
  411. call writech(progress_window,"Ignore  >" BOLD_TXT||IGNORE||PLAIN_TXT NL)
  412. call writech(progress_window,"(*) = match (-) = ignored" NL)
  413. end
  414.  
  415. call seek(SLIST,0,B)
  416. do forever
  417. TARGET = word(readln(SLIST),1)
  418. if eof(SLIST) then leave
  419. CHECK =  index(upper(TARGET),upper(KEYWORD))
  420. if CHECK = 0 then iterate
  421.    if CHECK >= 1 then do
  422.    call IGNORE_CHECK
  423.       if result = 1 then do; call writech(progress_window,"-" ); IGNORED = IGNORED + 1; end
  424.       if result = 0 then do
  425.       HITS = HITS + 1
  426.       call writech(progress_window,"*" )
  427.       call writeln(HLIST,TARGET)
  428.       end
  429.    end
  430. end
  431.  
  432. SEARCH_ABORTED:
  433. call close(SLIST)
  434. call close(HLIST)
  435. call close(progress_window)
  436.  
  437. if HITS ~= 0 then do
  438. call DELFILE(HITLIST'.old')
  439. address command
  440. 'rename 'HITLIST 'to 'HITLIST'.old'
  441. end
  442.  
  443. if HITS = 0 then do
  444. call rtezrequest("No matches found containing '"KEYWORD"'","OK",TITLE,STAG,)
  445. return
  446. end
  447.  
  448. call rtezrequest(HITS + IGNORED "matches found," IGNORED "ignored"NL,
  449.                  "-"HITS "remain-","VIEW|CANCEL",TITLE,STAG CTAG,)
  450. if rtresult = 0 then do
  451. return
  452. end
  453.  
  454. if rtresult = 1 then do
  455. BROWSE_LIST = HITLIST".old"
  456. BROWSETXT = HITS "matches on '"KEYWORD"'"
  457. call BROWSE
  458. end
  459.  
  460. return
  461.  
  462. /*************************** BROWSE routine ****************************/
  463. /********** *Must be passed file as argument for BROWSE_LIST* **********/
  464.  
  465. BROWSE:
  466.  
  467. if BROWSE_LIST = HITLIST".old" & ~exists(HITLIST".old") then do
  468. call rtezrequest("You haven't searched for anything yet","OK",TITLE,STAG,)
  469. return
  470. end
  471.  
  472. if open(BLIST,BROWSE_LIST,READ) ~= 1 then do
  473. if BROWSE_LIST = NEW_TEMP then ERRORTXT = "No new groups available"
  474. else ERRORTXT =  "Can't open" SEARCH_LIST
  475. call rtezrequest(ERRORTXT,"OK",TITLE,STAG,)
  476. return
  477. end
  478.  
  479. BODYTEXT = ""
  480. x = 0
  481. PAGE = 1
  482. LAST = DEF_MAX
  483.  
  484. do until eof(BLIST)           /* Do until the end of the file is found */
  485. BODYTEXT = ""                 /* Clear the BODYTEXT variable */
  486. POS.x = seek(BLIST,0,CURRENT) /* Store the current position in the file in case BACK is selected */
  487.  
  488.    do i = 1 to DEF_MAX
  489.    NG.i = readln(BLIST)
  490.      if NG.i = "" | eof(BLIST) then do
  491.      REPORT =  "..end of file"
  492.      LAST = i
  493.      leave
  494.      end
  495.    else REPORT = ""
  496.    BODYTEXT = BODYTEXT i || ")" word(NG.i,1) NL
  497.    end
  498.  
  499. BODYTEXT = BODYTEXT REPORT
  500. call rtezrequest("Browsing" BROWSETXT || NL || "PAGE" PAGE NL NL || BODYTEXT,">>|ADD|Leave|<<",TITLE,STAG,)
  501. if rtresult = 3 then do; call close(BLIST); return; end   /* Leave selected */
  502.  
  503. if rtresult = 0 then do      /* BACK selected */
  504.  
  505.    if PAGE = 1 then do       /* If already on first page just */
  506.    call seek(BLIST,0,BEGIN)  /* 'seek' the start of the file  */
  507.    iterate
  508.    end
  509.  
  510. BACK = x - 1
  511. call seek(BLIST,POS.BACK,BEGIN)
  512. x = x - 1
  513. PAGE = PAGE - 1
  514. iterate
  515. end
  516.  
  517. if rtresult = 2 then do
  518.    ACTION = "Add.."
  519.    MINI = 1
  520.    if eof(BLIST) then MAXI = min(i,LAST-1)
  521.    else MAXI = DEF_MAX
  522.    if MAXI = 0 then leave /*  NEW BIT */
  523.    call GETINDEX
  524.    if RESULT = 0 then iterate
  525.    call rtezrequest("Confirm add group new group - '"word(NG.INDEX,1)"'","OK|CANCEL",TITLE,STAG,)
  526.    if rtresult = 0 then iterate
  527.       else do
  528.       NEW = TOTAL + 1
  529.       ENTRY.NEW = word(NG.INDEX,1) DEF_DAYS
  530.       DAYS.NEW = DEF_DAYS
  531.       GROUP.NEW = word(ENTRY.NEW,1)
  532.       TOTAL = TOTAL + 1
  533.       CHANGES = CHANGES + 1  /* Update CHANGES                */
  534.       call UPDATE_TMP        /* Update T:Newsgroups           */
  535.       call UPDATE_VARS       /* Update the variables..        */
  536.       end
  537.    end
  538. PAGE = PAGE + 1
  539. x = x + 1
  540. end
  541.  
  542. call close(BLIST)
  543. return
  544. /*********** The ABOUT requester ***********/
  545.  
  546. ABOUT:
  547. call rtezrequest(TITLE "by Steve Collins" DATE NL NL,
  548.                  "If you find this script useful OR you want"NL,
  549.                  "to report a bug OR you have a suggestion as to"NL,
  550.                  "how to improve it then please drop me a line "NL,
  551.                  "and I'll also let you know of all updates" NL NL,
  552.                  "Thanks,"NL NL,
  553.                  "Send me a quid and I'll send you ALMan - The ultimate alias manager!"NL NL,
  554.                  "steve@stuffs.demon.co.uk"NL,
  555.                  "http://metro.turnpike.net/C/cheeky/INDEX.HTML","OK",TITLE,STAG,)
  556. return
  557.  
  558. /********* The SAVE routine **********/
  559.  
  560. SAVE:
  561. call DELFILE(NEWS_DIR || NEWS_NAME || ".bak")
  562. call DELFILE(NEW_TEMP)
  563.  
  564. address command
  565. 'rename' NEWS_DIR || NEWS_NAME 'TO' NEWS_DIR || NEWS_NAME || ".bak" 'QUIET'
  566. 'copy' TEMP_FILE 'to' NEWS_DIR 'QUIET NOREQ'
  567. call DELFILE(TEMP_FILE)
  568. return
  569.  
  570. /********** GET index of entry to modify **********/
  571.  
  572. GETINDEX:
  573. INDEX = rtgetlong(,"Enter index of entry to" ACTION || NL || BODYTEXT,TITLE,"OK|Cancel",STAG "rtgl_min =" MINI "rtgl_max =" MAXI,)
  574. if rtresult = 0 then return 0
  575. return INDEX
  576.  
  577.  
  578. /********** Update T:Newsgroups with any changes **********/
  579.  
  580. UPDATE_TMP:
  581. if open('AS',TEMP_FILE,WRITE) ~= 1 then do
  582.    call rtezrequest("Can't open Newsgroups file in T:","ABORT",TITLE,STAG,)
  583.    return
  584.    end
  585.  
  586. do i = 1 to TOTAL
  587. if ENTRY.i = "" then iterate
  588. call writeln('AS',ENTRY.i)
  589. end
  590.  
  591. call close('AS')
  592. return
  593.  
  594. /********** Update the variables with new entries in T:Newsgroups **********/
  595.  
  596. UPDATE_VARS:
  597. if open('AS',TEMP_FILE,READ) ~= 1 then do
  598.    call rtezrequest("Can't open Newsgroups file in T:","ABORT",TITLE,STAG,)
  599.    exit
  600.    end
  601.  
  602. TOTAL  = 0                                    /* Reset the TOTAL variable */
  603. do until eof('AS')
  604.  LINE =  readln('AS')                         /* Read each line of the Newsgroups file in T: */
  605.  if index(LINE,"#") | LINE = "" then iterate  /* If # or "" found then iterate */
  606.  TOTAL = TOTAL + 1                            /* Increase TOTAL by one for each Newsgroup found */
  607.  ENTRY.TOTAL = LINE                           /* Assign the GROUP + DAYS to the ENTRY. variable */
  608.  GROUP.TOTAL = word(LINE,1)                   /* Extract the GROUP and assign to GROUP. */
  609.  DAYS.TOTAL = word(LINE,2)                    /* Extract the DAYS and assign to DAYS */
  610. end
  611.  
  612. call close('AS')  
  613. return
  614.  
  615. /*********** Other stuff ************************/
  616.  
  617. BREAK_C:
  618. signal SEARCH_ABORTED
  619.  
  620.  
  621. /************************************************/
  622.  
  623. CREATE_NEWTMP:
  624.  
  625. if ~open(NEW,NEW_LIST,READ) then do
  626. return 0
  627. end
  628.  
  629. call open(LIST,NEW_TEMP,WRITE)
  630. do forever
  631. STRING = readln(NEW)
  632. if eof(NEW) then leave
  633. if STRING = "" then leave
  634. if ~verify(compress(STRING,xrange(0,9)),"//-::",) then iterate
  635. call writeln(LIST,STRING)
  636. end
  637. call close(LIST)
  638.  
  639. if SORT_NEW = 1 then do
  640. address command
  641. 'sort' NEW_TEMP NEW_TEMP
  642. end
  643.  
  644. return 1
  645.  
  646. /************************************************/
  647.  
  648. DELFILE:
  649.  
  650. parse arg file
  651. if exists(file) then do
  652. address command
  653. 'delete' file 'QUIET'
  654. return 1
  655. end
  656. else return 0
  657.  
  658. /************************************************/
  659.  
  660. IGNORE_CHECK:
  661.  
  662. if IGNORE = "" then return 0
  663. do y = 1 to words(IGNORE)
  664. CHECK = index(upper(TARGET),upper(word(IGNORE,y)))
  665. if CHECK = 0 then iterate    /* No match so continue with comparison */
  666. if CHECK >= 1 then return 1  /* Match found so return 1 to confirm   */
  667. end                          /* End of loop                          */
  668. return 0                     /* No matches found so return 0         */
  669.  
  670.  
  671.  
  672.  
  673.  
  674.